
class MyThread2 implements Runnable{
    @Override
    public void run() {
        for (int i=0; i<3;i++){
            System.out.println("实现Ruannable线程");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        MyThread2 t = new MyThread2();//Runnable接口实例化
        Thread thread = new Thread(t);
        thread.start();
        for (int i = 0; i <3 ; i++) {
            System.out.println("main线程");
            Thread.sleep(1000);
        }
    }
}
